import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialGroupVO, MaterialGroupForm, MaterialGroupQuery } from '@/api/goods/group/types';

/**
 * 查询品牌列表
 * @param query
 * @returns {*}
 */

export const listMaterialGroup = (query?: MaterialGroupQuery): AxiosPromise<MaterialGroupVO[]> => {
  return request({
    url: '/order/materialGroup/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询品牌详细
 * @param id
 */
export const getMaterialGroup = (id: string | number): AxiosPromise<MaterialGroupVO> => {
  return request({
    url: '/order/materialGroup/' + id,
    method: 'get'
  });
};

/**
 * 查询品牌详细
 */
export const getMaterialGroupAllList = (): AxiosPromise<MaterialGroupVO> => {
  return request({
    url: '/order/materialGroup/allList',
    method: 'get'
  });
};

/**
 * 新增品牌
 * @param data
 */
export const addMaterialGroup = (data: MaterialGroupForm) => {
  return request({
    url: '/order/materialGroup',
    method: 'post',
    data: data
  });
};

/**
 * 修改品牌
 * @param data
 */
export const updateMaterialGroup = (data: MaterialGroupForm) => {
  return request({
    url: '/order/materialGroup',
    method: 'put',
    data: data
  });
};

/**
 * 删除品牌
 * @param id
 */
export const delMaterialGroup = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/materialGroup/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param materialGroupId 客户端id
 * @param status 状态
 */
export function changeStatus(materialGroupId: string, status: string) {
  const data = {
    materialGroupId,
    status
  };
  return request({
    url: '/order/materialGroup/changeStatus',
    method: 'put',
    data: data
  });
}

export default {
  list:listMaterialGroup,
  get:getMaterialGroup,
  add:addMaterialGroup,
  update:updateMaterialGroup,
  del:delMaterialGroup,
  getMaterialGroupAllList:getMaterialGroupAllList
}